#pragma config(Hubs,  S1, HTMotor,  HTMotor,  HTServo,  HTMotor)
#pragma config(Sensor, S1,     ,               sensorI2CMuxController)
#pragma config(Sensor, S3,     IRseeker,       sensorHiTechnicIRSeeker1200)
#pragma config(Motor,  mtr_S1_C1_1,     LeftMotor,     tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S1_C1_2,     RightMotor,    tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S1_C2_1,     launcher,      tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S1_C2_2,     flag,          tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S1_C4_1,     LeftMotor2,    tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S1_C4_2,     RightMotor2,   tmotorTetrix, openLoop)
#pragma config(Servo,  srvo_S1_C3_1,    Flipper,              tServoNone)
#pragma config(Servo,  srvo_S1_C3_2,    servo2,               tServoNone)
#pragma config(Servo,  srvo_S1_C3_3,    servo3,               tServoNone)
#pragma config(Servo,  srvo_S1_C3_4,    servo4,               tServoNone)
#pragma config(Servo,  srvo_S1_C3_5,    servo5,               tServoNone)
#pragma config(Servo,  srvo_S1_C3_6,    servo6,               tServoNone)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#include "JoystickDriver.c"

task main()
{
waitForStart();

	//reset motors and encoders
	motor[LeftMotor]= 0;
	motor[LeftMotor2] = 0;
	motor[RightMotor] = 0;
	motor[RightMotor2] = 0;
	nMotorEncoder[LeftMotor] = 0;
	nMotorEncoder[RightMotor] = 0;
	nMotorEncoder[LeftMotor2] = 0;
	nMotorEncoder[RightMotor2] = 0;


while (nMotorEncoder[LeftMotor] > -300)
{
	motor[LeftMotor] = -40;
	motor[LeftMotor2] = -40;
	motor[RightMotor] = -40;
	motor[RightMotor2] = -40;
}

//reset motors and encoderz
	motor[LeftMotor]= 0;
	motor[LeftMotor2] = 0;
	motor[RightMotor] = 0;
	motor[RightMotor2] = 0;
	nMotorEncoder[LeftMotor] = 0;
	nMotorEncoder[RightMotor] = 0;
	nMotorEncoder[LeftMotor2] = 0;
	nMotorEncoder[RightMotor2] = 0;

wait1Msec(100);
servo[Flipper] = 224;
wait1Msec(1000);

while (nMotorEncoder[LeftMotor] > -2100)
{
	motor[LeftMotor] = -40;
	motor[LeftMotor2] = -40;
	motor[RightMotor] = -40;
	motor[RightMotor2] = -40;
}
//reset motors and encoders
	motor[LeftMotor]= 0;
	motor[LeftMotor2] = 0;
	motor[RightMotor] = 0;
	motor[RightMotor2] = 0;
	nMotorEncoder[LeftMotor] = 0;
	nMotorEncoder[RightMotor] = 0;
	nMotorEncoder[LeftMotor2] = 0;
	nMotorEncoder[RightMotor2] = 0;

	wait1Msec(10);

	while (nMotorEncoder[LeftMotor] > -1500)
	{
		motor[LeftMotor] = -40;
		motor[LeftMotor2] = -40;
		motor[RightMotor] = 40;
		motor[RightMotor2] = 40;
	}

	wait1Msec(10);

		//reset motors and encoders
	motor[LeftMotor]= 0;
	motor[LeftMotor2] = 0;
	motor[RightMotor] = 0;
	motor[RightMotor2] = 0;
	nMotorEncoder[LeftMotor] = 0;
	nMotorEncoder[RightMotor] = 0;
	nMotorEncoder[LeftMotor2] = 0;
	nMotorEncoder[RightMotor2] = 0;
		while (nMotorEncoder[LeftMotor] < 2000)
	{
		motor[LeftMotor] = 100;
		motor[LeftMotor2] = 100;
		motor[RightMotor] = 100;
		motor[RightMotor2] = 100;
	}
		//reset motors and encoders
	motor[LeftMotor]= 0;
	motor[LeftMotor2] = 0;
	motor[RightMotor] = 0;
	motor[RightMotor2] = 0;
	nMotorEncoder[LeftMotor] = 0;
	nMotorEncoder[RightMotor] = 0;
	nMotorEncoder[LeftMotor2] = 0;
	nMotorEncoder[RightMotor2] = 0;


}
